(module flatten (lib "eopl.ss" "eopl")
  (provide flatten)
;;1.26  
;;flatten: slist ==> list
;;usage: (flatten slist)
;;
;;examples:
;;(flatten '(a b c)) ==> (a b c)
;;(flatten '((a) () ((b) ()) () (c))) ==> (a b c)
;;(flatten '((a b) c (((d)) e))) ==> (a b c d e)
;;(flatten '(a b (() (c) ))) ==> (a b c)

(define flatten 
  (lambda (lst)
    (cond
      ((null? lst) ())
      ((list? (car lst)) (append (flatten (car lst)) (flatten (cdr lst))))
      (else (cons (car lst) (flatten (cdr lst))))
      )
    )
  )

(flatten '(a b c))
(flatten '((a) () ((b) ()) () (c))) 
(flatten '((a b) c (((d)) e)))
(flatten '(a b (() (c) )))
)